/**
 * Created by DELL on 2017/7/5.
 */
(function () {
    var $form=$("form");
    $form.validate({
        /**
         * ignore：忽略某些元素不验证
         * @type {String}
         * 例如：ignore: ".ignore" ，忽略所有的带ignore class 的标签
         */
        ignore: ".ignore",
        rules: {
            bannerType: {
                required: true
            },
            sort: {
                digits: true,
                max:98
            },
            linkAddress:{
                maxlength:120
            }
        }
    });
    window.formObject = $form;
    var userInfo=common.getLocalData(common.agentSysCacheWord).user;
    var $photo=$("#photo");
    var bannerPhotoGallery=$("#banner-photo").gallery({
        readOnly:false,
        title:"上传banner图片",
        url:window.globalHost +common.uploadImagePort,
        paramName:"uploadData",
        fileFolder:{folder:"banner",id:userInfo.id,fileName:"sys_banner_"+new Date().getTime()},
        returnPathName:"filePath",
        maxFiles:1,
        filePaths:[],
        uploadCallback:function () {
            var path=bannerPhotoGallery.getFilePaths();
            $photo.val(!!path.length?path.join(","):"")
        },
        deleteCallback:function () {
            var path=bannerPhotoGallery.getFilePaths();
            $photo.val(!!path.length?path.join(","):"");
        }
    });
}).call(this);
